package com.guguskins.back.controller;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.guguskins.back.entity.GuInviteLevel;
import com.guguskins.back.entity.vo.ResultVo;
import com.guguskins.back.service.GuInviteLevelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author mybatis-plus
 * @since 2021-06-01
 */
@RestController
@RequestMapping("/inviteLevel")
public class GuInviteLevelController {

    @Autowired
    private GuInviteLevelService inviteLevelService;

    @GetMapping("/back/list")
    public ResultVo findList(

    ) {
        return ResultVo.success(inviteLevelService.list(new LambdaQueryWrapper<GuInviteLevel>(){
            {
                orderByAsc(GuInviteLevel::getLevelValue);
            }
        }), "查找成功");
    }

    @PostMapping("/back/update")
    public ResultVo updateById(@RequestBody GuInviteLevel inviteLevel) {
        inviteLevelService.updateById(inviteLevel);
        return ResultVo.success("修改成功");

    }

    @PostMapping("/back/insert")
    public ResultVo insert(@RequestBody GuInviteLevel inviteLevel) {

        inviteLevelService.insert(inviteLevel);
        return ResultVo.success("添加成功");
    }
}
